package com.isasc.demo.pooled.commonpool;

import com.isasc.demo.pooled.mypool.ShareBike;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.PooledObjectFactory;
import org.apache.commons.pool2.impl.DefaultPooledObject;

/**
 * @author: ywy
 * @date: 2022-10-17
 * @desc:
 */
@Slf4j
public class ShareBikeManager implements PooledObjectFactory<ShareBike> {

    @Override
    public PooledObject<ShareBike> makeObject() throws Exception {
        return new DefaultPooledObject<>(ShareBike.init());
    }

    @Override
    public void destroyObject(PooledObject<ShareBike> p) throws Exception {
        log.info("destroyObject");
    }

    @Override
    public boolean validateObject(PooledObject<ShareBike> p) {
        return true;
    }

    @Override
    public void activateObject(PooledObject<ShareBike> p) throws Exception {
        log.info("activateObject");
    }

    @Override
    public void passivateObject(PooledObject<ShareBike> p) throws Exception {
        log.info("passivateObject");
    }
}
